package com.herench.bs.handler;

import com.herench.bs.agent.IOutpatientClinicAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * 加载排队叫号数据
 */

@Component
@Handler(code = "101111" ,name="获取患者ID")
public class GetPatientIdHandler extends AbstractMessageHandler {

    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception{
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        String idCard = requestMessage.getArgsPropertyStringValue("idCard");
        Assert.notNull(idCard, "idCard 不可为空！");
        String channelCode = requestMessage.getArgsPropertyStringValue("sysCode");
        Assert.notNull(channelCode, "sysCode 不能为空");
        String hospitalCode = requestMessage.getArgsPropertyStringValue("hospitalCode");
        IOutpatientClinicAgent outpatientClinicAgent = getCleverClinicContext().getApplicationContext().getBean(IOutpatientClinicAgent.class);
        Map<String,Object> res = outpatientClinicAgent.queryPatientInfo(channelCode,hospitalCode,idCard);
        responseMessage.setData(res);
        getPropertiesFromInvokerResultMap(responseMessage,res);
        return responseMessage;
    }
}
